﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Miv
{
    public abstract class MivCommand
    {
        protected FormMiv miv = null;

        public void SetTarget(FormMiv form)
        {
            miv = form;
        }

        public void Undo()
        {
        }
        
        public abstract void Do();
        public abstract bool CanUndo();

    }

    class MivCommandShift : MivCommand
    {
        int shift_x;
        int shift_y;

        public MivCommandShift(int x, int y)
        {
            shift_x = x;
            shift_y = y;
        }

        public override void Do()
        {
            if (miv != null)
            {
                miv.Shift(shift_x, shift_y);
            }
        }

        public override bool CanUndo()
        {
            return false;
        }
    }

    class MivCommandShiftTo : MivCommand
    {
        int dst_x;
        int dst_y;

        public MivCommandShiftTo(int x, int y)
        {
            dst_x = x;
            dst_y = y;
        }

        public override void Do()
        {
            if (miv != null)
            {
                miv.ShiftTo(dst_x, dst_y);
            }
        }

        public override bool CanUndo()
        {
            return false;
        }
    }

    class MivCommandZoomTo : MivCommand
    {
        float zoom_rate;

        public MivCommandZoomTo(float zoom_rate)
        {
            this.zoom_rate = zoom_rate;
        }

        public override void Do()
        {
            if (miv != null)
            {
                miv.ZoomTo(zoom_rate);
            }
        }

        public override bool CanUndo()
        {
            return false;
        }
    }
}
